Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
struct System.​Span`1
Assembly: System.Runtime
Provides a type-safe and memory-safe representation of a contiguous region of arbitrary memory.
Properties
public
bool
IsEmpty
Returns a value that indicates whether the current <see cref="T:System.Span`1" /> is empty.
public
T&
Item
public
int
Length
Returns the length of the current span.
Methods
public
void
Clear​()
Clears the contents of this <see cref="T:System.Span`1" /> object.
public
bool
Equals​(object obj)
obj
Not supported.
Returns Calls to this method are not supported.
Calls to this method are not supported.
Returns an enumerator for this <see cref="T:System.Span`1" /> .
public
int
GetHashCode​() Returns Calls to this method always throw a <see cref="T:System.NotSupportedException" /> .
Throws a <see cref="T:System.NotSupportedException" /> .
public
T&
GetPinnableReference​() Returns A reference to the element of the span at index 0, or <see langword="null" /> if the span is empty.
Returns a reference to an object of type T that can be used for pinning.
This method is intended to support .NET compilers and is not intended to be called by user code.
public
Span`1
Slice​(int start)
start
The zero-based index at which to begin the slice.
Returns A span that consists of all elements of the current span from <paramref name="start" /> to the end of the span.
Forms a slice out of the current span that begins at a specified index.
public
Span`1
Slice​(int start,
int length)
start
The zero-based index at which to begin this slice.
length
The desired length for the slice.
Returns A span that consists of <paramref name="length" /> elements from the current span starting at <paramref name="start" /> .
Forms a slice out of the current span starting at a specified index for a specified length.
public
T[]
ToArray​() Returns An array containing the data in the current span.
Copies the contents of this span into a new array.
public
string
ToString​() Returns The string representation of this <see cref="T:System.Span`1" /> object.
Returns the string representation of this <see cref="T:System.Span`1" /> object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .